package com.yilijk.base.network.bean;

import android.text.TextUtils;

import java.io.Serializable;

/**
 * Created by SHICHENG
 * on 2021/10/22.
 * 这个类是泛型类，可根据后端的返回字段修改
 */
public class ResponModel<T> implements Serializable {
    public static final int RESULT_SUCCESS = 200;
    public static final int RESULT_OTHER = 401;

    private String status;
    private int code;
    private boolean result;
    private String message;
    private String msg;
    private T data;

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public boolean isSuccess(){
        int i = 0;
        if (TextUtils.isEmpty(this.status)){
            if (code !=0){
                i = code;
            }else{
                if (this.isResult()){
                    i = 200;
                }
            }
        }else{
            i = Integer.valueOf(this.status).intValue();
        }
        return RESULT_SUCCESS == i;
    }

    public Boolean isOtherLogin() {
        int i = 0;
        if (TextUtils.isEmpty(this.status)){
            if (code !=0){
                i = code;
            }
        }else{
            i = Integer.valueOf(this.status).intValue();
        }
        return RESULT_OTHER == i;
    }

    public String getErrorMsg(){
        if (TextUtils.isEmpty(this.msg)){
            if (TextUtils.isEmpty(this.message)){
                return null;
            }else{
                return this.message;
            }
        }else{
            return this.msg;
        }
    }


}
